////////////////////////////////////////////////////////////////////////////////
/// @file    main.c
/// @author  AE TEAM
/// @brief   THIS FILE PROVIDES ALL THE SYSTEM FUNCTIONS.
////////////////////////////////////////////////////////////////////////////////
/// @attention
///
/// THE EXISTING FIRMWARE IS ONLY FOR REFERENCE, WHICH IS DESIGNED TO PROVIDE
/// CUSTOMERS WITH CODING INFORMATION ABOUT THEIR PRODUCTS SO THEY CAN SAVE
/// TIME. THEREFORE, MINDMOTION SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT OR
/// CONSEQUENTIAL DAMAGES ABOUT ANY CLAIMS ARISING OUT OF THE CONTENT OF SUCH
/// HARDWARE AND/OR THE USE OF THE CODING INFORMATION CONTAINED HEREIN IN
/// CONNECTION WITH PRODUCTS MADE BY CUSTOMERS.
///
/// <H2><CENTER>&COPY; COPYRIGHT MINDMOTION </CENTER></H2>
////////////////////////////////////////////////////////////////////////////////

// Define to prevent recursive inclusion
#define _MAIN_C_

// Files includes
#include "led.h"
#include "delay.h"


#include "tx_api.h"
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup MM32_Example_Layer
/// @{

////////////////////////////////////////////////////////////////////////////////
/// @addtogroup MAIN
/// @{

////////////////////////////////////////////////////////////////////////////////
/// @addtogroup MAIN_Exported_Constants
/// @{

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
TX_THREAD my_thread1;

TX_THREAD my_thread2;


void my_thread1_entry(ULONG thread_input)
{
  /* Enter into a forever loop. */
  while(1)
  {
    LED3_TOGGLE();
    LED4_TOGGLE();
    /* Sleep for 1 tick. */
    tx_thread_sleep(2000);
  }
}
void my_thread2_entry(ULONG thread_input)
{
  /* Enter into a forever loop. */
  while(1)
  {
    LED1_TOGGLE();
    LED2_TOGGLE();
    /* Sleep for 1 tick. */
    tx_thread_sleep(1000);
  }
}

void tx_application_define(void *first_unused_memory)
{
  /* Create my_thread! */
  tx_thread_create(&my_thread1, "My Thread 1",
  my_thread1_entry, 0x1234, first_unused_memory, 1024, 3, 3, TX_NO_TIME_SLICE, TX_AUTO_START);
  
  tx_thread_create(&my_thread2, "My Thread 2",
  my_thread2_entry, 0x1234, first_unused_memory+1024, 1024, 1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
}


////////////////////////////////////////////////////////////////////////////////
/// @brief  This function is main entrance.
/// @param  None.
/// @retval  0.
////////////////////////////////////////////////////////////////////////////////
s32 main(void)
{
    LED_Init();
    DELAY_Init();
    tx_kernel_enter( );
    while(1) {

    }
//    while(1) {
//        LED1_TOGGLE();
//        LED2_TOGGLE();
//        LED3_TOGGLE();
//        LED4_TOGGLE();
//        DELAY_Ms(1000);
//    }

}


/// @}

/// @}

/// @}
